package com.cmw.auntapp.presenter;

import android.text.TextUtils;

import com.cmw.auntapp.constant.API;
import com.cmw.auntapp.constant.CommandType;
import com.cmw.auntapp.core.base.BasePresenter;
import com.cmw.auntapp.core.base.IBaseView;
import com.cmw.auntapp.core.base.vo.DataResult;
import com.cmw.auntapp.core.util.ProgressRequestBody;
import com.cmw.auntapp.core.util.SharedPreferencesUtil;
import com.cmw.auntapp.core.util.ValidUtil;
import com.cmw.auntapp.model.GvlistModel;
import com.cmw.auntapp.model.UserModel;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.cmw.auntapp.constant.API.ATTACHMENT_TEXT_CONTENT;
import static com.cmw.auntapp.constant.API.ORDER_INFO_GET;
import static com.cmw.auntapp.constant.Constant.USER_INEMPID_KEY;
import static com.cmw.auntapp.constant.Constant.USER_MEMBERID_KEY;
import static com.cmw.auntapp.constant.Constant.USER_RNAME_KEY;
import static com.cmw.auntapp.constant.Constant.USER_USERAUTHTOKEN_KEY;

/**
 * @desc: 系统基础数据 Presenter
 * @author: chengmingwei
 * @date: 2021/05/04 06:55 AM
 * @contact: phone(微信同号):13922111489 / email: 340360491@qq.com
 */
public class SysBasePresenter extends BasePresenter<UserModel> {
    private IBaseView iBaseView;

    public SysBasePresenter(IBaseView iBaseView) {
        this.iBaseView = iBaseView;
        init();
    }

    /**
     * 获取合同协议内容
     * @param formType 业务类型
     */
    public void getAttachTextContent(String formType) {
        Map<String, String> params = new HashMap<>();
        params.put("formType", formType);
        get(API.parseAPI(ATTACHMENT_TEXT_CONTENT, params, "formType"), CommandType.GET);
    }

    /**
     * 文件上传
     * @param params
     * @param file
     * @param progressListener
     */
    public void uploadFile(Map<String, String> params, File file, ProgressRequestBody.ProgressListener progressListener){
        String formId = params.get("formId");
        if (TextUtils.isEmpty(formId)) {
            params.put("formId", "-1");
        }
        upload(API.ATTACHMENT_UPLOAD, params, file, progressListener);
    }

    /**
     * 获取省份数据
     */
    public void getProvinceList() {
        get(API.SYS_BASE_PROVINCE, CommandType.LIST);
    }

    /**
     * 获取获取籍贯列表数据
     */
    public void getNativePlaceList() {
        get(API.SYS_BASE_NATIVE_PLACE, CommandType.LIST);
    }

    /**
     * 获取服务类型
     * @return
     */
    public List<GvlistModel> getServiceTypeList(){
        List<GvlistModel> serviceTypeList = new ArrayList<>();
        GvlistModel gvlistModel = new GvlistModel();
        gvlistModel.setId(1l);
        gvlistModel.setName("钟点工");

        GvlistModel gvlistModel2 = new GvlistModel();
        gvlistModel2.setId(2l);
        gvlistModel2.setName("跑腿");

        GvlistModel gvlistModel3 = new GvlistModel();
        gvlistModel3.setId(3l);
        gvlistModel3.setName("月嫂");

        serviceTypeList.add(gvlistModel);
        serviceTypeList.add(gvlistModel2);
        serviceTypeList.add(gvlistModel3);
        return serviceTypeList;
    }

    @Override
    protected void success(CommandType commandType, DataResult dataResult) {
    }

    @Override
    protected IBaseView getView() {
        return iBaseView;
    }


}
